// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EntityNorthwind;

public partial class sample122 : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        sourceCode.Text = @"public void LinqToEntities90()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;var query = context<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ContactsSplit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.OfType<CustomerContactSplit>()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Cast<ContactSplit>()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Intersect(context.ContactsSplit.OfType<EmployeeContactSplit>().Cast<ContactSplit>())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ToList()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Select(c => new { type = c.GetType().ToString(), c });<br><br>&nbsp;&nbsp;&nbsp;&nbsp;ObjectDumper.Write(query);<br>}<br>";
    }

    public void ExecuteQuery(object src, EventArgs e)
    {
        using (context = new EntityNorthwind.EntityNorthwindContext(connstr))
        {
            LinqToEntities90();
        }
        this.output.Text = QueryOutput();
    }

	public void LinqToEntities90()
{
    var query = context
        .ContactsSplit
        .OfType<CustomerContactSplit>()
        .Cast<ContactSplit>()
        .Intersect(context.ContactsSplit.OfType<EmployeeContactSplit>().Cast<ContactSplit>())
        .ToList()
        .Select(c => new { type = c.GetType().ToString(), c });

    ObjectDumper.Write(query);
}

}
